package com.borko.healthcare.tapestry.pages;

import org.apache.tapestry5.PersistenceConstants;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SetupRender;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.Cookies;

public class MainPage {
	
	@Inject
	private Cookies cookies;
	
	@Property
	@Persist(PersistenceConstants.FLASH)
	private String userType;
	
	@SetupRender
	public void initialize() {
		if (userType == null) {
			userType = cookies.readCookieValue("userType");
		}
	}
	
	public boolean isLogedIn() {
		return cookies.readCookieValue("isUserLoged").equalsIgnoreCase("true") ? true : false;
	}
	
	public boolean isDoctor() {
		return userType.equalsIgnoreCase("doctor") ? true : false;
	}
	
	public boolean isPatient() {
		return userType.equalsIgnoreCase("patient") ? true : false;
	}
	
	public boolean isSuppiler() {
		return userType.equalsIgnoreCase("suppiler") ? true : false;
	}
	
	public boolean isPharmacist() {
		return userType.equalsIgnoreCase("pharmacist") ? true : false;
	}
}
